package com.ai.web.util;

import java.util.ArrayList;
import java.util.List;

public enum WorkStatus {
    
    NEW((byte)0, "未派发"), DISTRIBUTE((byte)1, "已派发"), CONFIRM((byte)2, "已确认"), MAINTAIN((byte)3, "维修中"),
    FINISHED((byte)4, "已完成"), COMMENT((byte)5, "已评价"), FEEDBACK((byte)6, "已反馈"), 
    DELETED((byte)7, "已删除"), WAITCONFIRM((byte)8, "待确认"),;

    private byte value;
    private String name;

    private WorkStatus(byte value, String name) {
        this.value = value;
        this.name = name;
    }

    /**
     * 获取值
     */
    public byte getValue() {
        return value;
    }

    /**
     * 获取名称
     */
    public String getName() {
        return name;
    }
    
    
    /**
     * 根据值获取枚举
     */
    public static WorkStatus getEnumByValue(Byte value){
        for (WorkStatus type : values())
            if (value == type.getValue())
                return type;
        return null;
    }
    
    public static String getName(Byte value) {
        for (WorkStatus w : WorkStatus.values()) {
            if (w.getValue() == value) {
                return w.name;
            }
        }
        return null;
    }
    
    public static List<WorkStatus> getList(){
    	List<WorkStatus> list = new ArrayList<WorkStatus>();
    	list.add(WorkStatus.NEW);
    	list.add(WorkStatus.DISTRIBUTE);
    	list.add(WorkStatus.CONFIRM);
    	list.add(WorkStatus.MAINTAIN);
    	list.add(WorkStatus.FINISHED);
    	list.add(WorkStatus.COMMENT);
    	list.add(WorkStatus.FEEDBACK);
    	list.add(WorkStatus.DELETED);
        list.add(WorkStatus.WAITCONFIRM);
        return list;
    }
}
